import java.util.Scanner;

public class Challenge4
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		String userSelection = "";
		
		System.out.print("Choose First Number: ");
		String numStr1 = input.next();
		double num1 = Double.parseDouble(numStr1);
		
		while (!userSelection.equals("Q") && !userSelection.equals("q"))
		{
			System.out.println("------------------------");
			System.out.println("Choose an operator.");
			System.out.println("(A)dd");
			System.out.println("(S)ubtract");
			System.out.println("(M)ultiply");
			System.out.println("(D)ivide");
			System.out.println("(Q)uit");
			
			System.out.println("Selection: ");
			userSelection = input.next();
			
			switch (userSelection)
			{
				case "A":
				case "a":
					System.out.println("You have selected ADD!");
					System.out.println("Choose Second Number: ");
					String numStr2 = input.next();
					double num2 = Double.parseDouble(numStr2);
					System.out.println(num1 + " + " + num2 + " = " + (num1 + num2));
					num1 = num1 + num2;
					
					break;
				case "S":
				case "s":
					System.out.println("You have selected SUBTRACT!");
					System.out.println("Choose Second Number: ");
					String numStr3 = input.next();
					double num3 = Double.parseDouble(numStr3);
					System.out.println(num1 + " - " + num3 + " = " + (num1 - num3));
					num1 = num1 - num3;
					break;
				case "M":
				case "m":
					System.out.println("You have selected MULTIPLY!");
					System.out.println("Choose Second Number: ");
					String numStr4 = input.next();
					double num4 = Double.parseDouble(numStr4);
					System.out.println(num1 + " * " + num4 + " = " + (num1 * num4));
					num1 = num1 * num4;
					break;
				case "D":
				case "d":
					System.out.println("You have selected DIVIDE!");
					System.out.println("Choose Second Number: ");
					String numStr5 = input.next();
					double num5 = Double.parseDouble(numStr5);
					System.out.println(num1 + " / " + num5 + " = " + (num1 / num5));
					num1 = num1 / num5;
					break;
				default:
					System.out.println("Invalid selection!");
					break;
				case "Q":
				case "q":
					System.out.println("You have QUIT!");
			}
		}
	}
}
